##
##		目的：提取DNAtool预测的靶mRNA
##		网站：http://carolina.imis.athena-innovation.gr/
##		时间：2021.4.22
##		作者：YHJ
##

from requests import get
from bs4 import BeautifulSoup

mirna = input("输入miRNA(例如：hsa-miR-107):")
page_all = int(input("一共有多少页(例如：27)："))

title = str(mirna) + ".txt"

url0 = "http://carolina.imis.athena-innovation.gr/diana_tools/web/index.php?r=lncbasev2%2Findex-experimental&miRNAs%5B%5D=" + str(mirna) + "&lncRNAs%5B%5D=&filters=0"

for k in range(page_all):
	page = "&page=" + str(k + 1)
	url = url0 + page
	webr = get(url)
	websoup = BeautifulSoup(webr.text, features="html.parser")
	gene_div = websoup.find_all("div", {"class": "first-level-block gene-name"})
	print("正在下载第{}页".format(str(k + 1)))
	for gene in gene_div:
		gene2 = str(gene)
		gene3 = gene2.split(">")[1]
		gene_name = gene3.split("<")[0]
		with open(title,"a") as f:
			f.write(gene_name + '\n')
print("下载完成")





